from http.client import responses
import requests
import urllib.request
import os
import sys

# 获取当前文件所在的目录
curPath = os.path.split(sys.argv[0])[0]

jfUrlHead = ""
# sh_601318 中国平安的股票代码
jfUrlStockCode = "" #默认是平安银行的股票代码
jfUrlFoot = ""


def getJfUrl():
    return jfUrlHead + jfUrlStockCode + jfUrlFoot


# 意图从九方智投上获取实时股票数据
# http://quote.eastmoney.com/sz000001.html
# jfUrlHead = "https://stock.9fzt.com/index/"
jfUrlHead = "http://quote.eastmoney.com/"
# sh_601318 中国平安的股票代码
# jfUrlStockCode = "sz_000001" #默认是平安银行的股票代码
jfUrlStockCode = "sz000001" #默认是平安银行的股票代码
# jfUrlFoot = ".html?from=BaiduAladdin"
jfUrlFoot = ".html"

jfUrl = 'https://stock.9fzt.com/index/sh_601318.html'
# jfUrl = getJfUrl()

url=jfUrl

print("目标路径->"+url)

response = requests.get(url)
# print(response.content)

# req=urllib.request.Request(url)
# resp=urllib.request.urlopen(req)
# data=resp.read().decode('utf-8')
# data=urllib.request

fp = open("temp.txt", "w", encoding='utf-8')

fp.write(response.content.decode('utf-8'))
fp.close